package ar.com.jsejtman.common.security.schema.service;

import ar.com.jsejtman.common.persistence.exception.DaoException;
import ar.com.jsejtman.common.security.schema.dao.SecurityUserDao;
import ar.com.jsejtman.common.security.schema.entity.SecurityUser;
import ar.com.jsejtman.common.service.definition.BaseService;
import ar.com.jsejtman.common.service.exception.EntitySavingException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Permite manipular usuarios de seguridad.
 * 
 * @author jsejtman
 */
@Service
@Transactional
public class SecurityUserService extends BaseService implements ISecurityUserService {

	@Override
	public final Long saveSecurityUser(final SecurityUser securityUser)
	        throws EntitySavingException {

		try {
			final SecurityUserDao dao = this.getDaoFactory().newDao(SecurityUserDao.class);

			return (dao.save(securityUser));

		} catch (final DaoException e) {
			throw new EntitySavingException(e.getMessage(), e);
		}
	}
}
